unit UnitCheque;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Buttons, StdCtrls, Mask, DBCtrls, variants, ExtCtrls, ComCtrls, Db, DBTables,
  Grids, DBGrids;

type

  TFCheque = class(TForm)
    DSTabelaCheque: TDataSource;
    tbcheque: TTable;
    PageCheque: TPageControl;
    TabCheque: TTabSheet;
    TabConsulta: TTabSheet;
    Panel1: TPanel;
    DBNavigator: TDBNavigator;
    Panel2: TPanel;
    ScrollBox: TScrollBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    EditEntrada: TDBEdit;
    EditNumero: TDBEdit;
    EditCliente: TDBEdit;
    EditAgencia: TDBEdit;
    EditConta: TDBEdit;
    EditBanco: TDBEdit;
    EditValor: TDBEdit;
    EditVencimento: TDBEdit;
    SpeedButton1: TSpeedButton;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    DBGrid1: TDBGrid;
    SpeedButton5: TSpeedButton;
    Label11: TLabel;
    EditDestino: TDBEdit;
    StatusBar1: TStatusBar;
    procedure SpeedButton1Click(Sender: TObject);
    procedure Label2Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormActivate(Sender: TObject);
    procedure SpeedButton5Click(Sender: TObject);
    procedure MaskEdit1Enter(Sender: TObject);
    procedure MaskEdit1Exit(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
   procedure AppHint(Sender : TObject);
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FCheque: TFCheque;

implementation



procedure TFCheque.AppHint(Sender: TObject);
begin
  StatusBar1.Panels[0].Text := Application.Hint;
end;

{$R *.DFM}


procedure TFCheque.SpeedButton1Click(Sender: TObject);
begin
     tbCheque.Insert;
      EditEntrada.SetFocus;
       //Contr := 'Novo';
end;

procedure TFCheque.Label2Click(Sender: TObject);
Var
LocCod:String;
begin
      LocCod:=Inputbox('Procura','Entre com o número do Cheque!','');
       if not tbCheque.locate('numero',LocCod,[])then
        ShowMessage('Cheque não encontrado');

end;

procedure TFCheque.SpeedButton2Click(Sender: TObject);
begin
     tbCheque.Edit;
       tbCheque.Post;
end;

procedure TFCheque.SpeedButton3Click(Sender: TObject);
begin
     tbCheque.Cancel;
end;

procedure TFCheque.FormClose(Sender: TObject; var Action: TCloseAction);
begin

	        Application.OnHint := nil;
  end;

procedure TFCheque.FormActivate(Sender: TObject);
begin
     PageCheque.ActivePage:=TabCheque;

 (tbcheque.fieldbyname ('entrada') as tdatetimefield).editmask := '99/99/9999';
 (tbcheque.fieldbyname ('vencimento') as tdatetimefield).editmask := '99/99/9999';
 (tbcheque.fieldbyname ('valor') as tfloatfield).DisplayFormat := '000000';

end;

procedure TFCheque.SpeedButton5Click(Sender: TObject);
begin
        if Application.MessageBox('Deseja deletar este cheque? ','Confirme',
        4 + MB_ICONQUESTION) = idYes then tbcheque.Delete;
end;
procedure TFCheque.MaskEdit1Enter(Sender: TObject);
begin
        keypreview:=False;
end;

procedure TFCheque.MaskEdit1Exit(Sender: TObject);
begin
        KeyPreview:=True;
end;

procedure TFCheque.FormKeyPress(Sender: TObject; var Key: Char);
begin
 if key=#13 then
       Perform(WM_nextdlgctl,0,0)
 Else if Key = #27 then
   Perform(WM_nextdlgctl,1,0)
end;

procedure TFCheque.FormShow(Sender: TObject);
begin
        tbcheque.Last;
end;

procedure TFCheque.FormCreate(Sender: TObject);
begin
     Application.OnHint := AppHint;
end;

procedure TFCheque.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var
  Comp: Trichedit; // * variável Comp da classe TMemo
  texto : string;
begin

  if key = vk_f1 then begin

  Comp := Trichedit.Create (Self);  // * cria o componente Memo
  Comp.Parent := Self;    // * exibe o componente criado

  if fileexists (extractfilepath(paramstr(0)) + '\ajuda\ajudacheque.txt') then
   comp.lines.loadfromfile (extractfilepath(paramstr(0)) + '\ajuda\ajudacheque.txt');

  texto := comp.Text;
  comp.Destroy;

  Showmessage (texto);
  end;

end;

end.
